<table class="w810" cellpadding="0" cellspacing="0" align="center">
    <?php foreach ($view->newcomments as $k => $comments) { ?>
        <tr>
            <td width="25%" height="30">
            </td>
            <td width="25%" height="30">
            </td>
            <td colspan="2" width="25%" height="30" align="right">
                <?php if($k == 0) {?>
                Sorter etter: 
                | <a href="?action=vote&order=total_like&sort=desc">Populære</a> | 
                <a href="?action=vote&order=created_time&sort=desc">Nyeste</a> | 
                <a href="?action=vote&order=created_time&sort=asc">Eldste</a>
                <?php } ?>
            </td>
        </tr>
        <tr>
        <?php foreach ($comments as $c) { ?>
            <td width="25%" align="center" valign="top">
                <div class="w190 po">
                    <div class="abs2 bg_trans" style="font-weight: bolder;" id="home-total-like-<?php echo $c['data_id']; ?>"><?php echo $c['total_like']; ?></div>

                    <a href="javascript:facebooktab.showLikeLightbox(<?php echo $c['data_id']; ?>);">
                            <div style="height: 127px;overflow: hidden;">
                                <img style="width: 191px;height: auto;" src="http://graph.facebook.com/<?php echo $c['facebook_user_id'];?>/picture/?type=large" alt="" />
                            </div>
                    </a>
                    <div class="bg_gray w190"><?php echo substr($c['name'], 0, 20); ?><?php if (strlen($c['name']) > 15) { echo "...";} ?></div>
                    <div class="bg_black w190 formatunlikebutton" id="like-area-<?php echo $c['data_id']; ?>">
                        <?php if(!$view->isEndOfContest) { ?>
                            <?php if ($view->isLogined && ($c['is_liked'] > 0)) { ?>
                                        <a href="javascript:contestapp.unlikecomment(<?php echo $c['data_id']; ?>)">
                                            <img src="<?php echo $view->config['template_url']; ?>assets/img/810/voted.png" alt="" />
                                        </a>
                            <?php } else { ?>
                                        <a href="javascript:contestapp.likecomment(<?php echo $c['data_id']; ?>)">
                                            <img src="<?php echo $view->config['template_url']; ?>assets/img/810/vote.png" alt="" />
                                        </a>
                            <?php } ?>
                        <?php } else { ?>
                            <a href="javascript:contestapp.unlikecomment(<?php echo $c['data_id']; ?>)">
                                <img src="<?php echo $view->config['template_url']; ?>assets/img/810/voted.png" alt="" />
                            </a>
                        <?php } ?>
                    </div>
                </div>
            </td>
        <?php } ?>
        </tr>
    <?php } ?>
</table>

<?php if($view->pagination['numberOfPage'] > 1){ ?>
<table cellpadding="0" cellspacing="0" class="w810" align="center">
    <tr>
        <td align="right">
            <ul class="pages">
                <?php for($i = 1; $i <= $view->pagination['numberOfPage'];$i++){ ?>
                <?php
                $orderString = "";
                if(isset($_GET['order'])) {
                    $sort = "DESC";
                    if(isset($_GET['sort']) && (strtolower($_GET['sort']) == "asc")){
                        $sort = "ASC";
                    }
                    $orderString = "&order={$_GET['order']}&sort={$sort}";
                }
                ?>
                    <li><a href="?action=vote<?php echo $orderString; ?>&p=<?php echo $i;?>" <?php if($view->pagination['currentPage'] == $i){ echo ' class="curr"'; }?>><?php echo $i;?></a></li>
                <?php } ?>
            </ul>
            <div style="clear:both"></div>
        </td>
    </tr>
</table>
<?php } ?>

<?php if($view->app_data) {?>
<script type="text/javascript">
    facebooktab.showLikeLightbox(<?php echo $view->app_data;?>);
</script>
<?php } ?>

<script type="text/javascript">
    contestapp.images.unlike = "<?php echo $this->config['template_url'];?>assets/img/810/voted.png";
</script>